package com.ssm.design.chain.handler.v3;

import com.ssm.design.chain.context.OrderHandleContextV3;
import com.ssm.design.common.enums.OrderTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CarOrderHandlers {

    // 折中方案... 支持多种类型 //
    /**
     * 汽车订单创建
     *
     * @return
     */
    @Bean(name = "createOrderByCar")
    public AbstractOrderHandlerV3 createOrderByCar() {
        return new CreateOrderHandler() {
            @Override
            protected OrderTypeEnum getTypeEnum() {
                return OrderTypeEnum.Car;
            }

            @Autowired
            private ApplicationContext applicationContext;

            @Override
            public void doHandle(OrderHandleContextV3 context, Object... args) {
                System.out.println("car order create ....");
            }
        };
    }

    /**
     * 汽车订单返利
     *
     * @return
     */
    @Bean(name = "rebateOrderByCar")
    public AbstractOrderHandlerV3 rebateOrderByCar() {
        return new RebateOrderHandler() {
            @Override
            protected OrderTypeEnum getTypeEnum() {
                return OrderTypeEnum.Car;
            }

            @Autowired
            private ApplicationContext applicationContext;

            @Override
            public void doHandle(OrderHandleContextV3 context, Object... args) {
                System.out.println("car order rebate ....");
            }
        };
    }
    // 折中方案... 支持多种类型 //
}
